// 整体布局
import Layout from '../components/Layout'

// hidden: true 隐藏路由
// alwaysShow: true 当路由下面的 children 只有一个时将路由提前，不显示当前路由

const routes = [
    // 首页
    {
        path: '/',
        component: Layout,
        redirect: '/home',
        alwaysShow: true,
        meta: {
            title: '首页',
            icon: 'el-icon-house',
            hidden: true
        },
        children: [
            {
                path: 'home',
                component: () => import('../views'),
                meta: {
                    title: '首页',
                    icon: 'el-icon-house'
                }
            },
            {
                path: 'myInfo',
                component: () => import('../views/MyInfo'),
                meta: {
                    title: '个人中心',
                    hidden: true
                }
            }
        ]
    },
    // 商品管理
    {
        path: '/goods',
        component: Layout,
        meta: {
            title: '商品管理',
            icon: 'el-icon-shopping-bag-2'
        },
        children: [
            {
                path: 'goodsList',
                component: () => import('../views/goods/GoodsList'),
                meta: {
                    title: '商品列表'
                }
            },
            {
                path: 'goodsParams',
                component: () => import('../views/goods/GoodsParams'),
                meta: {
                    title: '商品参数'
                }
            },
            {
                path: 'goodsCategories',
                meta: {
                    title: '商品分类'
                },
                component: () => import('../views/goods/GoodsCategories')
            },
            {
                path: 'goodsAdd',
                meta: {
                    title: '添加商品',
                    hidden: true
                },
                component: () => import('../views/goods/GoodsAdd')
            }
        ]
    },
    // 店铺管理
    {
        path: '/stores',
        component: Layout,
        meta: {
            title: '店铺管理',
            icon: 'el-icon-office-building'
        },
        children: [
            {
                path: 'storeList',
                component: () => import('../views/stores/StoreList'),
                meta: {
                    title: '店铺列表'
                }
            }
        ]
    },
    // 订单管理
    {
        path: '/order',
        component: Layout,
        meta: {
            title: '订单管理',
            icon: 'el-icon-tickets'
        },
        children: [
            {
                path: 'orderList',
                component: () => import('../views/order/OrderList'),
                meta: {
                    title: '订单列表'
                }
            }
        ]
    },
    // 登录页
    {
        path: '/login',
        component: () => import('../views/Login'),
        meta: {
            title: '登录',
            hidden: true
        }
    },
    // 注册页
    {
        path: '/register',
        component: () => import('../views/Register'),
        meta: {
            title: '注册',
            hidden: true
        }
    },
    // 404页
    // 这个路由一定要放在最后，匹配不到上面的路由，就匹配404路由
    {
        path: '*',
        meta: {
            title: '404错误',
            hidden: true // 隐藏路由
        },
        component: () => import('../views/error/404')
    }
]

export default routes
